<template>
    <div>
      <div class="header_search_nav search_form">
        <div class="ipt_left">
          <el-form ref="queryForm" :model="queryParams" label-width="80px">
            <el-row :gutter="24">
              <el-col :span="8">
                <div class="timebox">
                  <el-form-item label="日期时间" prop="date">
                    <timer
                      flag="T"
                      ref="timer"
                      :timer.sync="queryParams.date"
                      @query="IntHandle"
                    ></timer>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="4">
                <el-form-item label="发卡门店" prop="storeId">
                  <el-select
                    v-model="queryParams.storeId"
                    placeholder="请选择"
                    filterable
                    @change="handleQuery"
                  >
                    <el-option
                      v-for="(item, index) in $store.state.user.stores"
                      :key="index"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="消费门店" prop="storeIdSub">
                  <el-select
                    v-model="queryParams.storeIdSub"
                    placeholder="请选择"
                    filterable
                    @change="getList"
                  >
                    <el-option
                      v-for="(item, index) in $store.state.user.stores"
                      :key="index"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="会员卡号" prop="cardNumber">
                  <el-input
                    v-model="queryParams.cardNumber"
                    class="w-300"
                    placeholder="请输入会员卡号"
                    @keyup.enter.native="getList"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="手机号" prop="mobile">
                  <el-input
                    v-model="queryParams.mobile"
                    class="w-300"
                    placeholder="请输入手机号"
                    @keyup.enter.native="getList"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="账单号" prop="orderNo">
                  <el-input
                    class="w-200 text-left"
                    v-model="queryParams.orderNo"
                    placeholder="账单号查询"
                    @keyup.enter.native="getList"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
  
        <div class="btn_right">
          <button class="btn1" @click="handleQuery">筛选</button>
          <button class="btn2" @click="resetQuery">重置</button>
        </div>
      </div>
  
      <div class="table_card">
        <!-- 上部分 title -->
        <div class="table_card_top">
          <span class="solid_left1"></span>
          <div class="table_card_title">会员解冻消费</div>
        </div>
  
        <div class="table_list">
          <el-table
            :data="MemberTradingList"
            stripe
            style="width: 100%"
            v-loading="loading"
          >
            <el-table-column prop="chargingTime" label="账单时间" width="180px">
            </el-table-column>
            <el-table-column prop="orderNo" label="关联账单" width="180px">
            </el-table-column>
            <el-table-column prop="createName" label="操作员工" width="120px">
            </el-table-column>
            <el-table-column prop="cardStoreName" label="发卡门店" width="220px">
            </el-table-column>
            <el-table-column prop="storeName" label="消费门店" width="220px">
            </el-table-column>
            <el-table-column prop="customerName" label="客户姓名" width="120px">
            </el-table-column>
            <el-table-column prop="typeDesc" label="操作类型" width="120px">
            </el-table-column>
            <el-table-column
              prop="customerMobile"
              label="客户手机号"
              width="120px"
            >
            </el-table-column>
            <el-table-column prop="cardNumber" label="会员卡号" width="130px">
            </el-table-column>
            <el-table-column
              prop="statementPrincipal"
              label="变动本金"
              width="130px"
            >
            </el-table-column>
            <el-table-column
              prop="statementGiveMoney"
              label="变动赠金"
              width="120px"
            >
            </el-table-column>
            <el-table-column
              prop="surplusPrincipal"
              label="结余本金"
              width="120px"
            >
            </el-table-column>
            <el-table-column
              prop="surplusGiveMoney"
              label="结余赠金"
              width="120px"
            >
            </el-table-column>
            <el-table-column prop="surplusBalance" label="卡片余额">
            </el-table-column>
          </el-table>
          <pagination
            :total="total"
            :page.sync="queryParams.pageNo"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </div>
      </div>
    </div>
  </template>
    
  <script>
  import {
    getStatementPageList,
    getStatementPageListTotal,
  } from "@/api/business/MemberTrading";
  import { dayDataTime } from "@/utils/utils";
  import timer from "@/components/getTime/timer";
  export default {
    name: "EryuoaStoreMembersUnfreeze",
    components: { timer },
    data() {
      return {
        MemberTradingList: [],
        MemberTradingTotal: {}, // 统计记录
        loading: false,
        value: "",
        // 查询参数
        queryParams: {
          cardNumber: "",
          mobile: "",
          orderNo: "",
          storeId: "",
          storeIdSub: "", // 消费门店
          type: "",
          pageNo: 1,
          pageSize: 10,
          storeId: "",
          date: [],
          startDate: "",
          endDate: "",
          updateThew:'Y',
        },
        total: 0,
        exportLoading: false,
        TypeOptions: [
          {
            value: 1,
            label: "充值",
          },
          {
            value: 2,
            label: "消费",
          },
          {
            value: 3,
            label: "钱包调整",
          },
          {
            value: 4,
            label: "会员卡转账-转入",
          },
          {
            value: 5,
            label: "会员卡转账-转出",
          },
          {
            value: 6,
            label: "退卡",
          },
          {
            value: 7,
            label: "订单返结账",
          },
          {
            value: 8,
            label: "充值反结账",
          },
          {
            value: 9,
            label: "预约支付",
          },
          {
            value: 10,
            label: "预约取消",
          },
          {
            value: 11,
            label: "预约回退",
          },
          {
            value: 12,
            label: "退卡回退",
          },
        ],
      };
    },
  
    mounted() {},
  
    created() {},
  
    methods: {
      IntHandle() {
        this.handleQuery();
      },
  
      // 筛选
      handleQuery() {
        this.queryParams.pageNo = 1;
        this.getList();
        this.getStatementPageTotal();
      },
  
      /** 重置按钮操作 */
      resetQuery() {
        this.resetFormData("queryForm");
        this.$refs.timer.startAndEnds("T");
      },
  
      // 表单重置
      resetFormData(formName) {
        console.log(this.$refs[formName]);
        this.$nextTick(() => {
          this.$refs[formName].resetFields();
        });
      },
  
      // 会员解冻消费
      getList() {
        this.loading = true;
        let query = JSON.parse(JSON.stringify(this.queryParams));
  
        if (!!query.date && query.date.length > 0) {
          query.startDate = this.queryParams.date[0];
          query.endDate = this.queryParams.date[1];
          delete query.date;
        } else {
          this.$message.error("日期时间不能为空");
          this.loading = false;
          return false;
        }
        getStatementPageList(query)
          .then((res) => {
            console.log(res);
            this.loading = false;
            const { code, data } = res;
            if (code === 0) {
              this.MemberTradingList = data.list;
              this.total = data.total;
            }
          })
          .catch((err) => {
            this.loading = false;
          });
      },
      getStatementPageTotal() {
        let queryData = JSON.parse(JSON.stringify(this.queryParams));
  
        if (!!queryData.date && queryData.date.length > 0) {
          queryData.startDate = this.queryParams.date[0];
          queryData.endDate = this.queryParams.date[1];
          delete queryData.date;
        } else {
          return false;
        }
        getStatementPageListTotal(queryData)
          .then((res) => {
            const { code, data } = res;
            if (code === 0) {
              this.MemberTradingTotal = data;
            }
          })
          .catch((err) => {
            this.loading = false;
          });
      },
    },
  };
  </script>
    
    <style lang="scss" scoped>
  .solid_left1 {
    margin-left: 24px;
  }
  .goodTop {
    width: 100%;
    height: 48px;
    background: #ffffff;
    display: flex;
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.6);
    line-height: 48px;
    padding-left: 16px;
    .good_list {
      margin-right: 32px;
    }
  
    .good_active {
      color: #0052d9;
      border-bottom: 1px solid #0052d9;
    }
  }
  
  .w-200 {
    width: 200px;
    background: #ffffff;
    border-radius: 4px;
  }
  
  .client_name {
    font-size: 14px;
    font-weight: 400;
    color: #0052d9;
  }
  
  .give {
    height: 40px;
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.85);
    margin-top: 40px;
    line-height: 40px;
  }
  
  .el-form-item {
    margin-bottom: 20px;
  }
  
  .recharge_form {
    padding: 10px 24px;
  }
  
  .memberName {
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.85);
  }
  .el_row_item {
    margin-bottom: 10px;
  }
  .el_row_date {
    margin-top: 20px;
  }
  .el_row_reason {
    margin-top: 10px;
  }
  
  .el_row_date {
    .el-form-item {
      margin-bottom: 0px;
    }
  }
  
  .Order_box {
    display: flex;
    margin-left: -50px;
    .select_ipt {
      width: 130px;
      margin-right: 10px;
    }
  }
  
  .pay_ipt {
    margin-left: 50px;
  }
  
  .order_ipt {
    margin-left: -120px;
  }
  
  .timebox {
    margin-top: 10px;
  }
  </style>
    